<?php get_main_menu("receptionist") ?>
<?php 
mysql_select_db($database_drycleaners_conn, $drycleaners_conn);
$query_get_order = "SELECT person.first_name,
       person.last_name,
       `order`.created_date,
       `order`.id,
	   sum(order_payment.amount) as amount,
	   order_payment.created_date as payment_date,
       branch.name,
       `order`.order_no
  FROM    (   (   drycleaners.`order` `order`
               INNER JOIN
                  drycleaners.branch branch
               ON (`order`.branch_id = branch.id))
           INNER JOIN
              drycleaners.customer customer
           ON (`order`.customer_id = customer.id))
       INNER JOIN
          drycleaners.person person
       ON (customer.person_id = person.id)
	   LEFT OUTER JOIN
	   		order_payment
		ON (order_payment.order_id = order.id)
		  Where order.branch_id='".$_SESSION['branch_id']."'
		  GROUP BY order.id
      	  ORDER BY order.id DESC
		  ";
$get_order = mysql_query($query_get_order, $drycleaners_conn) or die(mysql_error());
$row_get_order = mysql_fetch_assoc($get_order);
$totalRows_get_order = mysql_num_rows($get_order);
?>
<?php include"includes/table_settings.php"?>
  <div>
  <a href="."><img src="images/back-button.png" width="30" height="30" title="Back" /></a><a href=".?order_add&action=Add">
  <img src="images/add-button.jpg" width="30" height="30" title="Add <?php echo $object_name ?>" /></a></div> 
    <div class="module_title">Custmer Orders
  </div> 
              <table cellpadding="0" cellspacing="0" border="0" id="dataTable">
                <thead>
                  <tr>
                    <th>Id</th>
                    <th>Order No</th>
                    <th>Branch</th>
                    <th>Customer</th>
                    <th>Created Date</th>
                    <th></th>
                    <th></th>
                    <th></th>
                    <th></th>
                  </tr>
                </thead>
                <tbody>
                  <!--Loop start, you could use a repeat region here-->
  <?php 
  
  do{
	  $approved_time=$row_get_order['approved_date'];
	  ?>
    <!--Loop start, you could use a repeat region here-->
    <tr>
      <td><?php echo $row_get_order['id']?></td>
      <td><?php echo $row_get_order['order_no']?></td>
      <td><?php echo $row_get_order['name']?></td>
      <td><?php echo $row_get_order['first_name']." ".$row_get_order['last_name']?></td>	
      <td><?php echo date("d-M-Y H:i:s",strtotime($row_get_order['created_date']))?></td>
            <td>
            <?php if($row_get_order['payment_date']==""){?>
            <a href=".?<?php get_child_link("0000-00-00 00:00:00","order_item_approve_view","order_item_view");?>= true&amp;order_id=<?php echo $row_get_order['id']; ?>&back_page=order_view"><input name="" value="Items" type="submit" id="edit_forms"/></a>
            <?php }else{?>
                        <a href=".?<?php get_child_link("0000-00-00 00:00:00","order_item_payment_view","order_item_payment_view");?>= true&amp;order_id=<?php echo $row_get_order['id']; ?>&back_page=order_view"><input name="" value="Items" type="submit" id="edit_forms"/></a>
            <?php }?>
            </td>
            <td><a href=".?<?php get_child_link("0000-00-00 00:00:00","suborder_view","suborder_view");?>= true&amp;order_id=<?php echo $row_get_order['id']; ?>&back_page=order_view"><input name="" value="Transfers" type="submit" id="edit_forms"/></a></td>
      <td>
	  <?php if($row_get_order['payment_date']==""){?>
	  <?php   get_edit_link("0000-00-00 00:00:00","order",$row_get_order['id']);}else{
		  echo $row_get_order['amount']."/=";
		  }?></td>
      <td>
	  <?php if($row_get_order['payment_date']==""){?>
	  <?php   get_delete_link("0000-00-00 00:00:00","order",$row_get_order['id'],"Transfered");} else{echo "<b>Payment Made</b>";}?>
      </td>
    </tr>
    <?php }while($row_get_order=mysql_fetch_assoc($get_order));?>
                  <!--Loop end-->
                </tbody>
              </table>
<?php
mysql_free_result($get_order);
?>